﻿#include "FileOutput.h"
#include "Application.h"
#include "Transient.h"

FileOutput::FileOutput(const Configuration& cfg)
  : Output(cfg)
  , _system(*(_app.GetSystem()))
  , _executioner(static_cast<Transient&>(*(_app.GetExecutioner())))
  , _file_base(Get<std::string>("file", "file_out"))
  , _interval(Get<int>("interval", 1))
  , _out_initial(Get<bool>("out_initial", false))
{
}

void FileOutput::Init() {}

void FileOutput::Execute() {}

std::string FileOutput::FileName()
{
  return _file_base;
}

bool FileOutput::ShouldOutput()
{
  auto current_step = _executioner.CurrentStep();
  if (current_step == 0)
    return _out_initial;
  else if (current_step == _executioner.NumStep())
    return true;
  else
    return current_step % _interval == 0;
}
